package com.lvfeng.tool;

import com.lvfeng.tool.chars.RandomTool;
import com.lvfeng.tool.chars.encrypt.EncryptUtil;
import com.lvfeng.tool.chars.encrypt.MD5Util;
import com.lvfeng.tool.chars.encrypt.SHA1;
import com.lvfeng.tool.weather.WeatherAPI;

import java.io.UnsupportedEncodingException;
import java.util.Random;

public class TestTools {
	public static void main(String[] args){

//		String myKey = "love10240wsw";		//秘钥
//		EncryptUtil des = new EncryptUtil(myKey, "utf-8");//解密接口代码
		//---------000.对象和json的各种转换------------
		//---------001.天气预报测试------------
//		String res = WeatherAPI.getWeatherWeek("1", des.deCode(WeatherAPI.APP_KEY_WEATHER), des.deCode(WeatherAPI.SIGN_WEATHER), "json");
//		System.out.println("一周天气：" + res);
		//当前
//		String res2 = WeatherAPI.getNowWeather("1", des.deCode(WeatherAPI.APP_KEY_WEATHER), des.deCode(WeatherAPI.SIGN_WEATHER), "json");
//		System.out.println("当前天气：" + res2);
		//PM25
//		String res3 = WeatherAPI.getCityList(des.deCode(WeatherAPI.APP_KEY_WEATHER), des.deCode(WeatherAPI.SIGN_WEATHER), "json");
//		System.out.println("PM25指数：" + res3);
		
//		NowPM25 wea = (NowPM25)JSONChange.jsonToObj(new NowPM25(), res3);	//具体对象接收结果集
//		System.out.println("是否成功"+wea.getSuccess()+"结果集"+wea.getResult().getCitynm());
//		System.out.println("---------------------对象转json------------------");
//		String jsonStr = JSONChange.objToJson(wea);
//		System.out.println("反转结果："+jsonStr);
		/* 
		 * 
		 */
		//-------------002.加密解密【DES】--------------
//		try {
//			String str = "被加密字符串";
//			String key = "密钥";	// 自定义密钥，当然这里是举例，接口加密完成
//			EncryptUtil des = new EncryptUtil(key, "utf-8");
//			System.out.println("加密前的字符：" + str);
//			String pass = des.enCode(str);
//			System.out.println("加密后的字符：" + pass);
//			System.out.println("------开始解密-----");
//			String sour = des.deCode(pass);
//			System.out.println("解密后：" + sour);
//		}catch(Exception e) {
//			e.printStackTrace();
//		}
		//-------------003.加密解密【MD5】--------------
//		String str4 = "Love you forever!";	//3be83eba81ee5cf4d6d13e27905b4bf7
//		System.out.println(MD5Util.MD5Encode(str4, "utf-8", false));	//源字符串，utf8编码，小写
		//-------------004.加密解密【SHA】--------------
//		String str5 = "Love you forever!"; //1c5e444b2afebfba72b31eb9f537fe8f8b19a631
//		System.out.println(SHA1.sign(str5, "SHA-1"));	//支持类型：SHA-1 MD5 SHA-256 SHA-384
		//-------------005.分段加密解密【RSA】--------------
		//-------------006.随机生成汉字---------------------
//		System.out.println(RandomTool.randomText(4));
		//-------------007.随机生成指定范围内的整数
//		System.out.println(RandomTool.randomInteger(100,1));
		//-------------008.随机生成大小写字母和数字混合的字符串
//		System.out.println(RandomTool.randomMixString(9));
		//-------------009.随机生成大小写字母----------------
//		System.out.println(RandomTool.randomEnglishLetter(5,"A"));




	}
}
